package com.yeyks.search.utils;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;

/**
 * @author pfy
 */
@Slf4j
public class RestHighLevelClientLogUtil {

    public static void log(SearchRequest searchRequest){
        try {
            log.info("es查询语句------{}",XContentHelper.toXContent(searchRequest.source(), XContentType.JSON, ToXContent.EMPTY_PARAMS, false).toBytesRef().utf8ToString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
